import ResManager from "../core/ResManager";
import UIBase from "../core/UIBase";

const { ccclass, property } = cc._decorator;

@ccclass
export default class HallView extends UIBase {

    @property({ type: cc.Prefab, tooltip: CC_DEV && '小游戏预制' })
    public GameItem: cc.Prefab = null;

    games: cc.Node = null;
    lbVersion: cc.Label = null;

    protected onLoad(): void {
        this.games = this.node.getChildByName('games');
        this.lbVersion = this.node.getChildByName('version').getComponent(cc.Label);
        this.lbVersion.string = '1.0.0';
    }

    start() {
        let config = ResManager.ins().getRes('config_smallGame');
        cc.log(config)
        for (let k in config) {
            let data = config[k];
            let node = cc.instantiate(this.GameItem);
            this.games.addChild(node);
            let ctrl = node.getComponent('GameItem');
            ctrl && ctrl.init(data);
        }
    }
}
